package com.itheima.edu.info.manager.service;

import com.itheima.edu.info.manager.dao.StudentDao;
import com.itheima.edu.info.manager.domain.Student;

public class StudentService {
    StudentDao studentDao = new StudentDao();

    public boolean addStudent(Student stu) {
        return studentDao.addStudent(stu);
    }

    public boolean isExists(String id) {
        boolean a = false;
        Student[] student = studentDao.findAllStudent();
        for (int i = 0; i < student.length; i++) {
            Student s = student[i];
            if (s != null && s.getId().equals(id)) {
                a = true;
                break;
            }
        }
        return a;
    }

    public Student[] ckid() {
        Student[] ckid = StudentDao.findAllStudent();
        boolean a = false;
        for (int i = 0; i < ckid.length; i++) {
            if (ckid[i] != null) {
                a = true;
            }
        }
        if (a) {
            return ckid;
        } else {
            return null;
        }
    }

    public void byetid(String id) {
        StudentDao studentDao = new StudentDao();
        studentDao.byetid(id);
    }

    public void xgid(Student stu, String id) {
        StudentDao studentDao = new StudentDao();
        studentDao.xgid(stu, id);
    }
}